import { NodeStatus } from "../NodeStatus";
import { ActionNode } from "./ActionNode";



/**
 * 同步动作节点
 */
export abstract class SyncActionNode<T> extends ActionNode<T> {

    constructor(name: string,blackboard: T) {
        super(name,blackboard);
    }

    // throws if the derived class return RUNNING.
    public Evaluate(): NodeStatus {
        const stat = super.Evaluate();
        if (stat === NodeStatus.RUNNING) {
            throw new Error('SyncActionNode MUST never return RUNNING');
        }
        return stat;
    }

    public Halt() {
        this.status = NodeStatus.IDLE;
    }
}